package com.smh.a03exerciseDemo1;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test2 {
    public static void main(String[] args) throws IOException {

        //^异或
        //相同为flase
        //不同为true
        System.out.println(100 ^ 10);
        //按位异或
        System.out.println(110 ^ 10);
        //发现,如果一个数字异或另一个数字两次,得到它本身

        //加密
        FileInputStream fis = new FileInputStream("day26-code\\file\\asd\\img.png");

        FileOutputStream fos = new FileOutputStream("day26-code\\file\\asd\\ency.png");

        byte[] bytes = new byte[1024 * 1024];
        int len;
        while ((len = fis.read(bytes)) != -1) {
            for (int i = 0; i < bytes.length; i++) {
                bytes[i] = (byte) (bytes[i] ^ 10);
            }
            fos.write(bytes, 0, len);
        }
        fos.close();
        fis.close();


    }
}
